package com.xxgc.helloworld.config;

import com.xxgc.helloworld.interceptor.JWTInterceptors;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;

/**
 * @program: helloword
 * @description: 拦截器配置
 * @author: liutao
 * @create: 2022-03-07 16:11
 **/
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    //配置拦截器规则
    public void addInterceptors(InterceptorRegistry registry){
        //swagger相关
        ArrayList<String> swagger = new ArrayList<>();
        swagger.add("/*.html");
        swagger.add("/swagger-resources/**");
        swagger.add("/webjars/**");
        swagger.add("/v2/**");
        swagger.add("/swagger-ui.html/**");
        //apipost 软件
        registry.addInterceptor(new JWTInterceptors())
                .addPathPatterns("/**")//需要进行token验证的
                .excludePathPatterns("/login/namePassLogin")//放行的
                .excludePathPatterns(swagger);//swagger相关
    }
}